import numpy as np # linear algebra
import pandas as pd  # data processing, CSV file I/O
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("boston_housing.csv")

cols = df.columns
fig = plt.figure()
# Calculates pearson co-efficient for all combinations，通常认为相关系数大于0.5的为强相关
data_corr = df.corr()
sns.heatmap(data_corr,annot=True)
print(data_corr.shape)

# 得到相关系数的绝对值，通常认为相关系数的绝对值大于0.5的特征为强相关
data_corr1 = data_corr.abs()
plt.subplots(figsize=(13, 9))
sns.heatmap(data_corr1,annot=True)

# Mask unimportant features,突出重要信息
sns.heatmap(data_corr1, mask=data_corr1 < 0.5, cbar=False)

#plt.savefig("house_coor.png" )
plt.show()